/**
 * @author wangxiaowei
 * 部门查询
 */
var sort = null;  
function initdepartmentlist(){
	 Ext.BLANK_IMAGE_URL=Ext.get('basePath').getValue()+"ajaxFramework/ext-2.1/resources/images/default/s.gif";
	var colModel = new Ext.grid.ColumnModel([
		{header:'序号',dataIndex:'orderNo',menuDisabled : true},
		{header:'部门名称',dataIndex:'deptName',menuDisabled : true},
		{header:'备注',dataIndex:'remarks',menuDisabled : true},
		{header:'级别',dataIndex:'levelNo',menuDisabled : true},		
		{header:'状态',dataIndex:'start',menuDisabled : true},
		{header:'操作',dataIndex:'operate',menuDisabled : true,renderer:function(s,m,rec){
		return "<a  href=javascript:selectdeptuser("+$.trim(rec.data.id) +")>查看部门下的人员</a>";
		}},
		{header:'id',dataIndex:'id',hidden:true}
	]);
	var url = Ext.get('url').getValue();
	sort = new Ext.data.JsonStore({
		url:url,
		fields:['orderNo','deptName','remarks','levelNo','start','operate','id'],
		root:'root',
		totalProperty:'totalProperty'
	});
	var bbar = new Ext.PagingToolbar({
		pageSize:10,
		store:sort,
		displayInfo:true,
		emptyMsg:'没有记录'
	});
	
	var grid = new Ext.grid.GridPanel({
		title:'部门列表',
		cm:colModel,
		renderTo:'topic-grid',
		store:sort,
		loadMask:true,
		autoHeight:true,
		tbar:[{
			 text: '添加',
             iconCls: 'silk-add',
             handler:function(){
             	window.location.href=Ext.get('basePath').getValue()+'tjsinfo/tjsoa/system/addUserForm.do';
             }
		}],
		bbar:bbar,
		viewConfig:{
			forceFit:true
		}
	});
	sort.load();
}
/**
 * 查询部门下的用户生成树放到WINDOW中
 * @param {} deptid
 */
function selectdeptuser(deptid){
	 var url = Ext.get('basePath').getValue()+'tjsinfo/tjsoa/system/userByDepartment.do?departmentid='+deptid;
	 var load = new Ext.tree.TreeLoader({
	 	  dataUrl:url
	 });
	 var root = new Ext.tree.AsyncTreeNode({
	 	id:'0',
	 	text:'天津利达粮油有限公司'
	 })
	 var tree = new Ext.tree.TreePanel({
	 		x:5,
	 		y:5,
        	autoScroll: true,
        	animate: true,
        	containerScroll: true,
        	border: true,
        	frame:true,
	        loader:load,
	        height:467,
	        width:505
	    });
	tree.setRootNode(root); 
	var win = new Ext.Window({
		title:'人员列表',
		width:520,
		height:500,
		modal:true,
		frame:true,
		closeAction:'hide',
		items:tree
	});
	win.show();
}